<cfcomponent extends="assets.calgrants.com.Base">

	<cffunction name="emailPassword" access="public" output="no" returntype="boolean">
		<cfargument name="email" type="string" required="yes" />
		<cfset var emailConfig = StructNew() />
		<cfinvoke component="UserService" method="read" returnvariable="user">
			<cfinvokeargument name="email" value="#arguments.email#" />
		</cfinvoke>
		<cfif user.RecordCount eq 1>
			<cfif NOT user.approved>
				<cfinvoke component="UserService" method="read" returnvariable="approvedUsers">
					<cfinvokeargument name="organization_id" value="#user.organization_id#" />
					<cfinvokeargument name="role" value="Organizer" />
				</cfinvoke>
			</cfif>
			<cfmail to="#user.email#" from="#request.personality.email#" subject="Your Cash for College password" type="html">
				<cfoutput>
					<p>Greetings from Cash for College!</p>
					
					<p>Your password is <strong>#user.password#</strong>.</p>
					
					<cfif user.approved>
						<p>You can login to the Cash for College Workshop Management System at <a href="http://www.calgrants.org/organizers">http://www.calgrants.org/organizers</a>.</p>
					<cfelseif NOT user.approved>
						<p>
							However, you cannot login to the Workshop Mangement System because your account is not approved.
							
							<cfif approvedUsers.RecordCount gt 0>
								Please contact one of the following users in your organization to approve your account.
								<ul>
									<cfloop query="approvedUsers">
										<li>#approvedUsers.first_name# #approvedUsers.last_name# - #approvedUsers.phone# or <a href="mailto:#approvedUsers.email#">#approvedUsers.email#</a></li>
									</cfloop>
								</ul>
							<cfelse>
								Please contact Cash for College at <a href="mailto:#request.personality.email#">#request.personality.email#</a> to approve your account.
							</cfif>							
						</p>					
					</cfif>
					
					<p>Please delete this message to help protect your account.</p>
				</cfoutput>
			</cfmail>
			<cfreturn true>
		<cfelse>
			<cfreturn false>			
		</cfif>
	</cffunction>
	
	<cffunction name="setSessionProperty" access="public" output="no" returntype="boolean">
		<cfargument name="name" required="yes" />
		<cfargument name="value" required="yes" />
		<cflock scope="session" timeout="20" type="exclusive">
			<cfif arguments.name eq "authUser.paId">
				<cfset session.authUser.paId = arguments.value />
			</cfif>
			<cfif arguments.name eq "authUser.oapId">
				<cfset session.authUser.oapId = arguments.value />
			</cfif>
		</cflock>
		<cfreturn true />
	</cffunction>
	
</cfcomponent>

